<script setup>
  import {ref} from "vue";

  const a=ref('')
  const b=ref(parseInt(Math.random()*100+1))
  console.log(b.value)
  const c=ref('')
  const f=()=>{
    if (!/^\d+$/.test(a.value)){
      alert('你干嘛！')
      return;
    }
    if (eval(a.value<b.value)){
      c.value='猜小了'
    }else if (eval(a.value>b.value)){
      c.value='猜大了'
    }else {
      c.value='恭喜你猜对了'
    }
    console.log(a.value,typeof a.value)
  }


</script>

<template>
  <h1>猜数字练习</h1>
  <input type="text" v-model="a">
  <button @click="f">猜一猜</button>
  <h3>{{c}}</h3>
</template>

<style scoped>

</style>